<template>
	<view>

		<view class="bgCol bg-blue tc">
		
			<scroll-view scroll-y class="padding-left padding-right" style="padding-top:60rpx;">
				<u-notice-bar :text="text1" bgColor="#9acafc" color="#ffffff" class="border-radius" @tap="go('/pages/my/page?id=27')"></u-notice-bar>
			</scroll-view>
			<view class="margin-top">
				本期分润总额
			</view>
			<view class="text-xxl margin-top margin-bottom">
				{{dataObj.cashmoneysum || 0.00}}
			</view>
			<view class="">
				本月成功交易：{{dataObj.summoney || 0.00}}
			</view>
		</view>
		<view class="cu-bar bg-white" style="border-bottom:1px #efefef solid;">
			<view class="action text-bold text-black">
				商户动态
			</view>
		</view>
		<view class="padding bg-white">
			
			<view class="cu-list grid col-2">
				<view class="cu-item" v-for="(item, index) in mainList" :key="index">
					<navigator :url="item.path" hover-class="none">
						<view class="flex">
							<image :src="item.icon" style="width:80rpx;height:80rpx;" mode=""></image>
							<view class="tl margin-left">
								<view class="">{{ item.num }}</view>
								<text>{{ item.title }}</text>
							</view>
						</view>
					</navigator>
				</view>
			</view>
		</view>
		
		<view class="bg-white margin-top">
			
			<view class="cu-bar" style="border-bottom:1px #efefef solid;">
				<view class="action text-bold text-black"> 
					本月交易统计
				</view>
				<view class="content">
					
				</view>
				<view class="action">
					
					<navigator url="transactionStatistics" hover-class="none">
						更多月份
					</navigator>
				</view>
			</view>
			
			<view class="charts-box margin">
			    <qiun-data-charts type="line" :chartData="chartData" :enableScroll="true" :ontouch="true" />
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			title:null,
			list:[],
			text1: '《安全声明》诈骗短信，切勿轻信',
			mainList: [
				{
					color: 'orange',
					icon: '/static/icon/shop3.jpg',
					num: 0,
					title: '审核驳回',
					path: './reviewRejected?shopMenu=5'
				},
				{
					color: 'orange',
					icon: '/static/icon/shop2.jpg',
					num: 0,
					title: '审核中(户)',
					path: './reviewRejected?shopMenu=1'
				},
				{
					color: 'blue',
					icon: '/static/icon/shop1.jpg',
					num: 0,
					title: '今日新增(户)',
					path: './reviewRejected?shopMenu=6'
				},
				{
					color: 'green',
					icon: '/static/icon/shop4.jpg',
					num: 0,
					title: '本月新增(户)',
					path: './reviewRejected?shopMenu=7'
				}
			],
			chartData:{
				type: 'line',
				// 'xAxis': {
				// 	'itemCount': 4
				// },
				categories: ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期日', ],
				series: [
					{
						name: "分润",
						data: [0,0,0,0,0,0,0]
					}
				]
			},
			dataObj: {},
			
		}
	},
	onLoad() {
	},
	onShow() {
		
		this.initDataList(1)
		this.getMerchantDynamics()
	},
	onReady() {
		if (!uni.getStorageSync("token")) {
			uni.navigateTo({
				url: '/pages/user/login'
			})
			return
		}
	},
	methods: {
		go(e) {
			uni.navigateTo({
				url: e
			})
		},
		safetyStatement () {
			uni.navigateTo({
				url: './safetyStatement'
			})
		},
		async initDataList (page) {
			this.list = []
			let params = {
				agentid: uni.getStorageSync("YNF_INFO").user_id,
				start_time: '',
				end_time: '',
				pay_type: 1,
				page: page,
				size: 20,
				order_page: 1,
				order_size: 10
			}
			const res = await this.$API({url: '/api/index/money_log',method:"POST", data: params})
			if (res.code === 1) {
				let x = []
				let y = []
				for (let item of res.data.date_price_money) {
					x.push(item.week_name)
					y.push(item.money)
				}
				this.chartData = {
					type: 'line',
					// 'xAxis': {
					// 	'itemCount': 4
					// },
					categories: x,
					series: [
						{
							name: "分润",
							data: y
						}
					]
				}
				this.dataObj = res.data
			}
			
			let params1 = {
				withid: 27,
			}
			const res1 = await this.$API({url: '/api/index/with',method:"GET", data: params1});
			this.text1 = res1.data.name;
		},
		async getMerchantDynamics () {
			let params = {
				user_id: uni.getStorageSync("YNF_INFO").user_id,
				leshuastatus: 8
			}
			const res = await this.$API({url: '/api/index/user_agent',method:"GET", data: params})
			if (res.code === 1) {
				this.mainList[0].num = res.data.leshua5
				this.mainList[1].num = res.data.leshua1
				this.mainList[2].num = res.data.day_add
				this.mainList[3].num = res.data.month_add
			}
		}
	}
}
</script>

<style lang="scss" scoped>
	
.cu-list.grid > .cu-item:after {
	border: none;
}
.bgCol {width:100%;height:400rpx;padding-top: 60rpx}
.uni-scroll-view {border-radius:50rpx;}
.border-radius {
	border-radius: 30rpx;
	padding: 6rpx 24rpx;
}
</style>
